package com.xdja;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.handler.codec.http.*;
import org.junit.jupiter.api.Test;

/**
 * description
 *
 * @author zk
 * @since 2018/9/25
 */
public class HttpResponseTest {

    @Test
    public void testEmbed() throws InterruptedException {
        EmbeddedChannel embeddedChannel = new EmbeddedChannel(new HttpResponseEncoder());

        HttpResponse httpResponse = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        embeddedChannel.writeOutbound(httpResponse);
        ByteBuf obj = embeddedChannel.readOutbound();
        byte[] allBytes = new byte[obj.readableBytes()];
        obj.readBytes(allBytes);

        for (int i = 0; i < allBytes.length; i++) {
            System.out.print(allBytes[i] + ",");
        }
    }
}
